package com.mlog.njyjy.ndop.share.sql.annotation;

import java.lang.annotation.*;

/**
 * <p>
 * 数据列操作
 * - 暂不支持复合主键
 * </p>
 *
 * @author <a href="mailto:yingxiufeng@mlogcn.com">alex</a>
 * @version v1.0, 2020/7/8
 */
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Column {


    /**
     * column definition in sql type
     * eg `varchar(128)` `bigint(128)`
     * @return
     */
    String definition() default "";

    /**
     * column comment
     * @return
     */
    String comment() default "";

    /**
     * 把pojo驼峰字段映射到下划线列名
     * @return
     */
    boolean underline() default true;

    /**
     * (Optional) Whether the column is a unique key.
     * 针对列的唯一性约束 每个 列会生成一个 unique key `xx` (`xx`)
     */
    boolean unique() default false;

    /**
     * (Optional) Whether the database column is nullable.
     */
    boolean nullable() default true;

    /**
     * TODO (Optional) Whether the column is included in SQL INSERT
     * statements generated by the persistence provider.
     */
    boolean insertable() default true;

    /**
     * TODO (Optional) Whether the column is included in SQL UPDATE
     * statements generated by the persistence provider.
     */
    boolean updatable() default true;

    /**
     * (Optional) The column length. (Applies only if a
     * string-valued column is used.)
     */
    int length() default 128;

    /**
     * (Optional) The precision for a decimal (exact numeric)
     * column. (Applies only if a decimal column is used.)
     * Value must be set by developer if used when generating
     * the DDL for the column.
     */
    int precision() default 0;

    /**
     * (Optional) The scale for a decimal (exact numeric) column.
     * (Applies only if a decimal column is used.)
     */
    int scale() default 0;

}
